new Vue({
    el: '.container-fluid',
    data: {
        user: {
            userId: localStorage.getItem("userId"),
            username: "",
            nickname: "",
            password: "",
            email: "",
            phoneNumber: ""
        }
    },
    created: function () {
        $("span.mr-2.d-none.d-lg-inline.text-gray-600.small").text(localStorage.getItem("nickName"));
        axios.get("http://localhost:8080/user/UserInfo", {
            params: {
                "userId": localStorage.getItem("userId")
            }
        }).then(response => {
            this.user.username = response.data.data.username;
            this.user.nickname = response.data.data.nickname;
            this.user.password = response.data.data.password;
            this.user.email = response.data.data.email;
            this.user.phoneNumber = response.data.data.phoneNumber;
        })
    },
    methods: {
        updateUserInfo: function () {
            axios.post("http://localhost:8080/user/UpdateUserInfo", this.user)
                .then(response => {
                    if (response.data.code != 200) {
                        alert(response.data.message)
                    }
                    localStorage.setItem("nickName", this.user.nickname)
                    location.href = "profile.html"
                })
        }
    }
})